package com.pg.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pg.entity.ycl.EipOperatingMechanism;
import com.pg.mapper.EipOperatingMechanismMapper;
import com.pg.service.EipOperatingMechanismService;
import com.pg.utils.Jpg2Base64Util;
import com.pg.utils.UploadFileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 操动机构 服务实现类
 * </p>
 *
 * @Author likl
 * @since 2020-10-26
 */
@Service
@DS("proxyDs")
@Primary
public class EipOperatingMechanismServiceImpl extends ServiceImpl<EipOperatingMechanismMapper, EipOperatingMechanism> implements EipOperatingMechanismService {

    @Autowired
    private EipOperatingMechanismMapper eipOperatingMechanismMapper;

    @Override
    public void saveOne(EipOperatingMechanism operatingMechanism) {
        if (operatingMechanism.getCheckResult() != null) {
            String filePath = "/root/" + operatingMechanism.getCheckResult();
            operatingMechanism.setCheckResultObj(UploadFileUtils.uploadFiles(Jpg2Base64Util.Jpg2Base64(filePath)));
            eipOperatingMechanismMapper.insert(operatingMechanism);
        } else {
            operatingMechanism.setCheckResultObj(null);
            eipOperatingMechanismMapper.insert(operatingMechanism);
        }
    }
}
